Return to main page

The Microchip PICmicro® Micrcontroller

Data sheets

The different aspects of the PIC16F627 is described in the following datasheets:

To help you with your application development, I have included the following "watch" files for the PIC16F84 and PIC16F62:


PICC Lite Example application

Before you get started working through the robot applications, you might want to try out \code\example\example.c after you have installed the MPLAB IDE and PICC Lite. As noted in the text, the \code\example\example.c code has some errors that you will have to work through. When you work through this application, you will discover that while PICC Lite and the MPLAB IDE are excellent tools, there can be a few confusing error messages that you will have to learn to work through.

The source code for \code\example\example.c is:

#include 

//  02.03.31 - Myke Predko
//
//  Example of a PICC Lite application
//
//  Demonstrate a simple error.
//
//
//  Hardware Notes:
//  PIC16F84 Running at 4 MHz
//  RB0 will be toggled at full speed
//  

//  Global Variables

//  Configuration Fuses
	__CONFIG(0x03FF1);			//  Set Configuration Fuses to:
						//   - XT Oscillator
						//   - 70 msecs Power Up Timer On
						//   - Watchdog Timer Off
						//   - Code Protection Off


//  Mainline
void main(void)				
{

	while (1 == 1) 				//  Toggle RB0
		RB0 = RB0 ^ 1

}  //  End of Mainline
    

Robot Application C Programming Template

The basis for all the applications in this book is the following code which can be found in the \code\template\template.c file on the CD-ROM.
#include 

//  Template for basic PICC Lite Program for Robots
//
//  Setup TMR0 to interrupt Mainline once every 1,024 usecs
//
//  02.03.28 - Updated to allow PIC16F627/PIC16F84 PICmicro MCUs
//  02.01.23 - Originally created by myke predko
//
//
//  Hardware Notes:
//  PIC16F84/PIC16F627 running at 4 MHz
//  PIC16F627 uses internal 4 MHz oscillator
//  External _MCLR connection required
//  


//  Configuration Fuses
#if defined (_16F84)
#warning PIC16F84 selected
	__CONFIG(0x03FF1);		//  PIC16F84 Configuration Fuses:
					//   - XT Oscillator
					//   - 70 msecs Power Up Timer On
					//   - Watchdog Timer Off
					//   - Code Protection Off
#elif defined(_16F627)
#warning PIC16F627 with internal oscillator selected
	__CONFIG(0x03F70);		//  PIC116F627 Configuration Fuses:
					//   - Internal Oscillator
					//   - RA6/RA7 Digital I/O
					//   - External Reset
					//   - 70 msecs Power Up Timer On
					//   - Watchdog Timer Off
					//   - Code Protection Off
					//   - BODEN Enabled
#else
#error Unsupported PICmicro MCU selected
#endif


//  Global Variables
volatile unsigned int RTC = 0;		//  Real Time Clock Counter


//  Interrupt Handler
void interrupt tmr0_int(void)		//  TMR0 Interrupt Handler
{

	if (T0IF) {

		T0IF = 0;		//  Reset Interrupt Flag

		RTC++;			//  Increment the Clock

//  Put mechalogic/elelogic interface code for 1 msec interrupt here

	}  //  endif

//  Put interrupt handlers for other mechalogic/elelogic interface code

}  //  End Interrupt Handler


//  Mainline
void main(void)				//  Template Mainline
{

	TMR0 = 0;			//  Reset the Timer for Start
	OPTION = 0x0D1;			//  Assign Prescaler to TMR0
					//   Prescaler is /4
	T0IE = 1;			//  Enable Timer Interrupts
	GIE = 1;			//  Enable Interrupts

//  Put hardware interface initialization code here

	while (1 == 1) {		//  Loop forever

//  Put robot biologic code here

	}  //  endwhile

}  //  End of Mainline